import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);
// import molle from './molle.js';
// import molle2 from './molle2.js';

export default new Vuex.Store({
  modules: {
    // molle,//测试模块1
    // molle2,//测试模块2
  },
  state: {
    TOKEN: null,
    msg: { name: 'a123' }
  },
  getters: {
    getValue: (state) => (key) => { return state[key] },
    getTOKEN: (state) => {
      if (state.TOKEN === null) {
        state.TOKEN = localStorage.getItem('TOKEN') || null;
      }
      return state.TOKEN
    },
  },
  mutations: {

    setValue: (state, obj) => { state[obj.key] = obj.value },
    setLocal: (state, value) => {
      state.key = value;
      localStorage.setItem('key', value);
    }
  },
  actions: {},
})